package com.ljx.itbbs.server.mall.service.adapter;

import com.ljx.itbbs.server.mall.domain.entity.CouponEntity;
import com.ljx.itbbs.server.mall.domain.entity.CouponRecordEntity;
import com.ljx.itbbs.server.mall.domain.enums.CouponUseEnum;
import com.ljx.itbbs.server.mall.domain.vo.req.CouponSaveReq;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-03-31  15:03
 */
public class CouponAdapter {
    public static CouponRecordEntity buildCouponRecordSave(Long userId, Long couponId) {
        CouponRecordEntity couponRecordEntity = new CouponRecordEntity();
        couponRecordEntity.setCouponId(couponId);
        couponRecordEntity.setUserId(userId);
        couponRecordEntity.setIsUse(CouponUseEnum.NOT_USE.getType());
        return couponRecordEntity;
    }

    public static CouponEntity buildCouponSave(CouponSaveReq req) {
        CouponEntity couponEntity = new CouponEntity();
        couponEntity.setName(req.getName());
        couponEntity.setMoney(req.getMoney());
        couponEntity.setBeginTime(req.getBeginTime());
        couponEntity.setEndTime(req.getEndTime());
        couponEntity.setStock(req.getStock());
        return couponEntity;
    }
}
